{% extends "base/base.html" %}
{% block css %} 
<link rel="stylesheet" href="/static/css/back.css">
{% endblock %}
{% block content %}
<h3 class="title">我上传的视频列表</h3>
<div class="list-box">
<a href="/add" class="btn">添加视频</a>
<table>
    <tr>
        <th>视频编号</th>
        <th>视频封面</th>
        <th>视频标题</th>
        <th>视频类型</th>
        <th>视频描述</th>
        <th>上传时间</th>
        <th>操作</th>
    </tr>
    {% if not res%}
    <tr><td colspan="5">暂无数据</td></tr>
    {% else %}
    {% for r in res%}
    <tr>
        <td><a href="/video/{{r._id}}">{{r._id}}</a></td>
        <td>
            {% if r.vimgid %}
            <img style="height:50px;width:auto" src="/getimg/{{r.vimgid}}" alt="">
            {% else %}
            无
            {% endif%}
        </td>
        <td>{{r.vname}}</td>
        <td>{{r.vtype}}</td>
        <td>{{r.vdesc}}</td>
        <td>{{r.uploadtime | strftime}}</td>
        <td><a class="btn text" onclick="delVideo('{{r._id}}')">下架视频</a></td>
    </tr>
    {% endfor %}
    {% endif %}
</table>
</div>
{% endblock %}
{% block script %}
<script>
    function delVideo(_id){
       let a = confirm("您确定要下架该视频吗？")
       console.log(a)
       if(a){
        $.post("/api/delVideo",{"id":_id},function(res){
            res = JSON.parse(res)
            alert(res.msg)
            if(res.code==200){
                location.reload()
            }
        })
       }
    }
</script>
{% endblock %}